#region Usings
using System.Collections.Generic;
using System.Linq;

using BK.Model;
using BK.Repositories.Abstract;
#endregion

namespace BK.Repositories.EF
{
    public class AccountsRepository : BaseRepository<Account>, IAccountsRepository
    {
        #region IAccountsRepository Members
        public AccountsRepository(BkDataContext dataContext) : base(dataContext)
        {
        }

        public Account GetBy(int userId, string accountName)
        {
            Account result = (from account in ObjectSet
                              where (account.UserId == userId) &&
                                    (account.Name == accountName)
                              select account).FirstOrDefault();

            return result;
        }

        public IEnumerable<Account> GetBy(int userId)
        {
            List<Account> result = (from account in ObjectSet
                              where (account.UserId == userId)
                              select account).ToList();
            return result;
        }
        #endregion
    }
}